package org.example.leetCode;

/**
 * @author Administrator
 */
public class MyPow {

    public static void main(String[] args) {
        MyPow myPow = new MyPow();
        double v = myPow.myPow(2.00000,
                -2147483648);
        System.out.println(v);
    }

    public double myPow(double x, int n) {
        if (n == 0) {
            if (x == 0) {
                return 0;
            }
            return 1;
        }
        if (n == 1) {
            return x;
        }
        if (n == -1) {
            return 1 / x;
        }
        double half = myPow(x, n / 2);
        double rest = myPow(x, n % 2);
        return half * half * rest;
    }
}
